package com.sea.empeno.service;

import javax.persistence.EntityManager;


import java.util.List;
import javax.management.RuntimeErrorException;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import com.sea.model.repository.*;
import com.sea.model.*;
import com.sea.util.*;


public class RenovarContratoService {

	
	 ContratoRepository contratoRepository;
		
		private EntityManager em;
		
		public RenovarContratoService(){
			em= Utilitario.getInstance().getEntityManager();
			contratoRepository= new ContratoRepository(em);
			
		}
		public void renovarContrato (Contrato c) throws RuntimeException{
				EntityTransaction tx=em.getTransaction();
				try {
					tx.begin();
					contratoRepository.update(c);
					tx.commit();
				} catch (Exception e2) {
					// TODO: handle exception
					e2.printStackTrace();
					tx.rollback();
					throw new RuntimeException("No se pudo registrar la venta");
				}

		}
		
}
